package com.ruitu.mall_98_2.mvp.model;

import com.ruitu.mall_98_2.dao.APIRetrofit;
import com.ruitu.mall_98_2.mvp.contract.OrderContract;
import com.ruitu.router_module.bean.api.BaseResult;
import com.ruitu.router_module.bean.api.PageModel;
import com.ruitu.router_module.bean.order.Order;
import com.ruitu.router_module.bean.order.SmallOrder;

import java.util.List;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class OrderModel implements OrderContract.Model {
    @Override
    public Observable<BaseResult<PageModel<SmallOrder>>> getOtherAllOrders(String accountId, String status, String page, String size) {
        return APIRetrofit.getDefault().getOtherAllOrders(accountId, status, page, size)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    @Override
    public Observable<BaseResult<Order>> orderInfo(String accountId) {
        return APIRetrofit.getDefault().orderInfo(accountId)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }

    @Override
    public Observable<BaseResult> deleteOrder(String orderId) {
        return APIRetrofit.getDefault().deleteOrder(orderId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    @Override
    public Observable<BaseResult> cancelOrder(String orderId) {
        return APIRetrofit.getDefault().cancelOrder(orderId)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }

    @Override
    public Observable<BaseResult> qrsh(String odId) {
        return APIRetrofit.getDefault().qrsh(odId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    @Override
    public Observable<BaseResult<String>> getOrderTracesByJson(String odId) {
        return APIRetrofit.getDefault().getOrderTracesByJson(odId)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
}
